package net.lab1024.sa.admin.module.business.order.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.admin.module.business.order.domain.form.OrderAddForm;
import net.lab1024.sa.admin.module.business.order.domain.form.OrderQueryForm;
import net.lab1024.sa.admin.module.business.order.domain.form.OrderUpdateForm;
import net.lab1024.sa.admin.module.business.order.domain.vo.OrderNum;
import net.lab1024.sa.admin.module.business.order.domain.vo.OrderVO;
import net.lab1024.sa.admin.module.business.order.service.OrderService;
import net.lab1024.sa.admin.module.system.type.domain.TypeEntity;
import net.lab1024.sa.admin.module.system.type.service.TypeService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.sql.ResultSet;
import java.util.List;

/**
 * 订单 Controller
 *
 * @Author syf
 * @Date 2025-05-16 10:02:50
 * @Copyright 畅想科技
 */

@RestController
@Tag(name = "")
public class OrderController {

    @Resource
    private OrderService orderService;
    @Resource
    private TypeService typeService;
    @Operation(summary = "分页查询 @author syf")
    @PostMapping("/order/queryPageByJdyId")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<PageResult<OrderVO>> queryPageByJdyId(@RequestBody @Valid OrderQueryForm queryForm) {
        return ResponseDTO.ok(orderService.queryPage(queryForm));
    }
    @Operation(summary = "分页查询 @author syf")
    @PostMapping("/order/queryPage")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<PageResult<OrderVO>> queryPage(@RequestBody @Valid OrderQueryForm queryForm) {
        return ResponseDTO.ok(orderService.queryPage(queryForm));
    }
    @Operation(summary = "分页查询 @author syf")
    @PostMapping("/order/queryOrderPage")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<PageResult<OrderVO>> queryPageOrderByTime(@RequestBody @Valid OrderQueryForm queryForm) {
        return ResponseDTO.ok(orderService.queryPageOrderByTime(queryForm));
    }
    @Operation(summary = "获取订单状态列表")
    @GetMapping("/order/queryType")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<List<TypeEntity>> queryShopPage(@RequestParam(defaultValue = "order_type") String key) {
        return typeService.getTypeList(key);
    }
    @Operation(summary = "获取订单状态列表")
    @GetMapping("/order/queryNum")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<List<OrderNum>> queryNum() {
        return orderService.setOrderNum();
    }
    @Operation(summary = "获取订单状态列表")
    @GetMapping("/order/queryContentType")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<List<TypeEntity>> queryContentPage(@RequestParam(defaultValue = "order_content") String key) {
        return typeService.getTypeList(key);
    }
//    @Operation(summary = "获取订单状态列表")
//    @GetMapping("/order/queryEnum")
//    @SaCheckPermission("support:order:query")
//    public ResponseDTO<ResultSet> queryShopPage() {
//        ResultSet enum1 = orderService.queryEnum().getData();
//        return ResponseDTO.ok(enum1);
//    }
    @Operation(summary = "添加 @author syf")
    @PostMapping("/order/add")
    @SaCheckPermission("support:order:add")

    public ResponseDTO<String> add(@RequestBody @Valid OrderAddForm addForm) {
        return orderService.add(addForm);
    }

    @Operation(summary = "更新 @author syf")
    @PostMapping("/order/update")
    @SaCheckPermission("support:order:update")

    public ResponseDTO<String> update(@RequestBody @Valid OrderUpdateForm updateForm) {
        return orderService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author syf")
    @PostMapping("/order/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return orderService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author syf")
    @GetMapping("/order/delete/{orderId}")
    @SaCheckPermission("support:order:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer orderId) {
        return orderService.delete(orderId);
    }
    @Operation(summary = "单个删除 @author syf")
    @GetMapping("/order/detail/{orderId}")
    @SaCheckPermission("support:order:query")
    public ResponseDTO<OrderVO> detail(@PathVariable @Valid String orderId) {
        return orderService.detail(orderId);
    }

}
